package com.hrm.model.daoimple;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;


import com.hrm.model.dao.PagingDAO;

public class PagingDAOImple   extends SqlMapClientDaoSupport implements PagingDAO{

	public int getCount(String searchType[], String searchValue[], String queryId, boolean isT) {
		Map<String, Object> params = new HashMap<String, Object>();
		
		if(searchType!=null){
			for(int i=0;i<searchType.length;++i){
				if(searchValue[i]!=null && searchValue[i].length()>0){
					if(isT){
						params.put(searchType[i], "%"+searchValue[i]+"%");
					}else{
						params.put(searchType[i], searchValue[i]);
					}
				}
			}
		}

		return ((Integer)this.getSqlMapClientTemplate().queryForObject(queryId, params)).intValue();
	}

	public List getList(String searchType[], String searchValue[], int pageSize,
			int curPage, String queryId, boolean isT) {
	
		Map<String, Object> params = new HashMap<String, Object>();
		
		if(searchType!=null){
			for(int i=0;i<searchType.length;++i){
				if(searchValue[i]!=null && searchValue[i].length()>0){
					if(isT){
						params.put(searchType[i], "%"+searchValue[i]+"%");
					}else{
						params.put(searchType[i], searchValue[i]);
					}
				}
			}
		}
		params.put("pageSize", new Integer(pageSize));
		params.put("curPage", new Integer(curPage));
		return this.getSqlMapClientTemplate().queryForList(queryId, params);
	}

	
	
	
	
}
